/*
Copyright (c) 2006 - 2008  Universitaet Osnabrueck, virtUOS
Authors: Markus Ketterl, Johannes Emden, Nils Schuhmacher, Andreas Rickling

This file is part of virtPresenter.

virtPresenter is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

virtPresenter is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with virtPresenter.  If not, see <http://www.gnu.org/licenses/>.
*/

package virtPresenter.commands
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.adobe.cairngorm.control.CairngormEventDispatcher;
	import virtPresenter.event.*;
	import virtPresenter.model.*;
	import flash.net.LocalConnection;
	
	/**
	 * Class handles when a user clicked the advanced button in the slide navigation.
	 * */
	public class AdvanceInPresentation implements ICommand {
		
		/**
		 * Construtor of AdvanceInPresentation.
		 * */		
		public function AdvanceInPresentation() {}
		
		/**
		 * Sets the VideoPlayer to the time of the next animationstep/step
		 * and therefor invoke a VideoPlayerTimeChangeEvent in the AdvancedScrubber.		 * 
		 * */	
		public function execute( event : CairngormEvent ): void {			    		   
			    
			    var model : virtPresenterLocator = virtPresenterLocator.getInstance();
			    var nextTimeStep:TimeStep=model.xmlParser.getNextStep(model.currentvideotime*1000);
			    var new_time:int=nextTimeStep.getTime();
			    var newTime_sec:Number=new_time/1000+0.5;			    
			    trace("AdvanceInPresentation. Advance to step/time (sec):" +nextTimeStep.getStep()+"/"+ newTime_sec);
			    //trace("AdvanceInPresentation. Current video time:" + model.currentvideotime);
			    model.netStream.seek(newTime_sec);
			   			    			
		}
	
		
	}
	
	
}